package cn.fan.testfunction.devise.single;

/**
 * 双重校验锁
 * 解决了线程安全问题， 也节省内存空间
 *
 * @author fgy
 * @version 1.0
 * @date 2021/11/11 10:26
 */
public class DoubleLockSingle {
    private volatile static DoubleLockSingle instance;

    private DoubleLockSingle() {
    }

    public static DoubleLockSingle getInstance() {
        if (instance == null) {
            synchronized (DoubleLockSingle.class) {
                if (instance == null) {
                    return new DoubleLockSingle();
                }
            }
        }
        return instance;
    }

}
